package cn.wolfcode.service.impl;

import cn.wolfcode.domain.MessageReplyHjc;
import cn.wolfcode.mapper.MessageReplyHjcMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IMessageReplyHjcService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageReplyHjcServiceImpl implements IMessageReplyHjcService {

    @Autowired
    private MessageReplyHjcMapper messageReplyHjcMapper;


    @Override
    public void save(MessageReplyHjc messageReplyHjc) {
        messageReplyHjcMapper.insert(messageReplyHjc);
    }

    @Override
    public void delete(Long id) {
        messageReplyHjcMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(MessageReplyHjc messageReplyHjc) {
        messageReplyHjcMapper.updateByPrimaryKey(messageReplyHjc);
    }

    @Override
    public MessageReplyHjc get(Long id) {
        return messageReplyHjcMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<MessageReplyHjc> listAll() {
        return messageReplyHjcMapper.selectAll();
    }

    @Override
    public List<MessageReplyHjc> selectById(Long id) {
        return messageReplyHjcMapper.getResult(id);
    }

    @Override
    public PageInfo<MessageReplyHjc> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize()); //对下一句sql进行自动分页
        List<MessageReplyHjc> messageReplyHjcs = messageReplyHjcMapper.selectForList(qo); //里面不需要自己写limit
        return new PageInfo<MessageReplyHjc>(messageReplyHjcs);
    }
}
